// Copyright (c) 2021 Presto Labs Pte. Ltd.
// Author: chensili

#include <gflags/gflags.h>

#include "coin2/strategy/dmm_strat/dmm_strategy.h"

DEFINE_bool(dry_run, false, "dry run");
DEFINE_string(driver, "", "driver config");
DEFINE_string(config, "", "strategy config");
DEFINE_int32(exit_after_sec, 3600, "");

int main(int argc, char* argv[]) {
  google::InitGoogleLogging(argv[0]);
  gflags::ParseCommandLineFlags(&argc, &argv, true);

  auto path = std::experimental::filesystem::path(FLAGS_driver);
  coin2::app::DriverConfig app_config;
  app_config.MergeFrom(coin2::base::config::DriverConfigFromJson(path));
  LOG(INFO) << "app_config: " << app_config.DebugString();

  coin2::strategy::dmm_strat::DmmStrategy strategy(
      FLAGS_config,
      FLAGS_dry_run,
      std::optional<int64_t>(),
      FLAGS_exit_after_sec);
  coin2::app::Driver driver(app_config, &strategy);
  driver.RegisterCleanupHandler();
  driver.Run();
  return 0;
}
